﻿<cfsilent>
	<cfscript>

		event.setArg("pageTitle", "教材管理 - 教材基础信息 - 教材详细信息");

		strAdvice = getProperty("serviceFactory").getBean("stringAdvice");
		dictAdvice = getProperty("serviceFactory").getBean("senateDictionaryAdvice");
		mathAdvice = getProperty("serviceFactory").getBean("senateMathAdvice");
		
		pubId = event.getArg("PubID");
		bookId = event.getArg("BID");

		bookExId = event.getArg("bookExistsID");
		
		currentTab = event.getArg("TabID", "labBookInfo");
		
		rs_bookEntity = queryNew("pid");
		
		targetArgs = structNew();
		
		/* 读取出版社统计信息 */
		sql = "	SELECT
					p.pid,p.publisher,p.book_count,p.pyid
				FROM
					t_publisher p
				WHERE
					p.pyid != '0'
				ORDER BY
					p.publisher";

		queryObj = new Query(datasource = application.dnsSlave);
		rs_pub = queryObj.execute(sql = sql).getResult();
		
		sql = "	SELECT
					DISTINCT p.pyid
				FROM
					t_publisher p
				WHERE
					p.pyid != '0'
				ORDER BY
					p.pyid";
		
		queryObj = new Query(datasource = application.dnsSlave);
		rs_pubIndex = queryObj.execute(sql = sql).getResult();
		
		if ( len(bookId) ) {

			/* 读取教材信息 */
			sql = "	SELECT
						b.pid,b.book_name,b.book_isbn,b.book_authors,p.publisher,b.book_edition,b.book_prise,b.book_stock,b.book_awards,
						b.pyidx,b.pyid,b.bid
					FROM
						t_book b INNER JOIN t_publisher p ON b.pid = p.pid
					WHERE
						b.bid = :bookId ";
			
			queryObj = new Query(datasource = application.dnsSlave);
			queryObj.addParam(name = "bookId", value = bookId, cfsqltype = "cf_sql_varchar");
			rs_bookEntity = queryObj.execute(sql=sql).getResult();
			
			structInsert(targetArgs, "PubID", rs_bookEntity.pid, true);
			
		}
					
	</cfscript>
</cfsilent>

<div id="headArea">
	<div class="uiHeader uiHeaderWithImage ptm">
		<div class="clearfix uiHeaderTop">
			<div class="uiHeaderActions rfloat">
				<a class="uiButton" href="<cfoutput>#buildURL('bookSchema', targetArgs)#</cfoutput>"><i class="mrs img btnPublish"></i><span class="uiButtonText">教材征订目录</span></a>
			</div>
			<div>
				<h2 class="uiHeaderTitle">
					<i class="uiHeaderImage img icon16x16 application"></i>教材详细信息 <cfif rs_bookEntity.recordCount>《<cfoutput>#rs_bookEntity.book_name#</cfoutput>》</cfif>
				</h2>
			</div>
		</div>
	</div>
</div>

<div class="UIElement">
	<ul class="senateFirstPage">
		<li>
			<div class="clearfix" id="summary">
			
				<div class="UItab">
					<div class="tabLables">
						<span <cfif currentTab eq "labPublisher">class="active"</cfif> id="labPublisher" tabTarget="Publisher">出版社列表</span>
						<span <cfif currentTab eq "labBookInfo">class="active"</cfif> id="labBookInfo" tabTarget="BookInfo">教材基本信息</span>
						<span <cfif currentTab eq "labBookEdit">class="active"</cfif> id="labBookEdit" tabTarget="BookEdit">修订教材信息</span>
						<span <cfif currentTab eq "labBookDelete">class="active"</cfif> id="labBookDelete" tabTarget="BookDelete">删除教材</span>
					</div>
				</div>
				<script language="javascript" type="text/javascript">
					//<![CDATA[
					<!--
					$(document).ready(function() {
						
						/* init Tab */
						$("div.tabContent").hide();
						$("div#" + $("div.tabLables span.active").attr("tabTarget")).show();
						
						$("div.tabLables > span").click(function(){
							var $targetID = $(this).attr("tabTarget");
							
							$("div.tabLables span").removeClass("active");
							$(this).addClass("active");
							
							$("div.tabContent").not('[id="' + $targetID + '"]').hide();
							$("div.tabContent#" + $targetID).show();
						});
						
					});
					
					// -->
					//]]>
				</script>
				
				<div id="Publisher" class="tabContent">

					<div class="noticeBlock">
						<div class="operation">
							<a class="uiButton uiButtonSpecial" href="<cfoutput>#buildURL('bookDownloadExcel')#</cfoutput>"><i class="mrs img btnDownload"></i><span class="uiButtonText">下载全部教材信息</span></a>
						</div>
						<h3>教材出版社信息</h3>
						<p><span class="img icon16x16 message"></span>这里列出的是现有教材征订目录的出版社信息. </p>
						<hr/>
						
						<div class="UIArrangeOper">
							<cfif rs_pubIndex.recordCount>
								<span>出版社索引</span>
                                <cfloop query="rs_pubIndex">
									<a class="opBtn Index letterFilter" href="#pos<cfoutput>#rs_pubIndex.pyid#</cfoutput>"><cfoutput>#rs_pubIndex.pyid#</cfoutput></a>
								</cfloop>
							</cfif>
						</div>
						
					</div>
							
					<div id="pubList">
							
						<cfloop query="rs_pubIndex">
                        		
							<div class="noticeBlock">
								<p><b><cfoutput>#rs_pubIndex.pyid#</cfoutput></b><a name="pos<cfoutput>#rs_pubIndex.pyid#</cfoutput>"></a></p>
								<hr/>
							</div>
								
							<div class="clearfix">
								<div class="UICardTable">
                                    <cfloop query="rs_pub">
										<cfif rs_pubIndex.pyid eq rs_pub.pyid>
											<cfset structInsert(targetArgs, "PubID", rs_pub.pid, true) />
											<dl <cfif listFind(pubId, rs_pub.pid)>class="warn"</cfif>>
												<dt>
													<a href="<cfoutput>#buildURL('bookSchema', targetArgs)#</cfoutput>">
														<em class="building"><!--imgholder--></em>
														<dd>
															<h3><cfoutput>#replace( replace(rs_pub.publisher, " ", "&not;", "all"), CHR(13), "&not;", "all")#</cfoutput></h3>
															<div>注册教材<span><cfoutput>#rs_pub.book_count#</cfoutput></span>本</div>
														</dd>
													</a>
												</dt>
											</dl>
										</cfif>
									</cfloop>
								</div>
							</div>
								
						</cfloop>
								
						<cfset structDelete(targetArgs, "PubID") />
								
					</div>
				</div>
						
				
				<cfif rs_bookEntity.recordCount>
					
					<script language="javascript" type="text/javascript">
						//<![CDATA[
						<!--
						function showBookModify() {
							
							$("div.tabLables span").removeClass("active");
							$("div.tabLables span#labBookEdit").addClass("active");
							
							$("div.tabContent[@id!='BookEdit']").hide();
							$("div.tabContent#BookEdit").show();
							
						}
						
						<cfif len(bookExId)>
						$(document).ready(function() {
							showBookModify();
						});
						</cfif>
						
						// -->
						//]]>
					</script>
					
					<div id="BookInfo" class="tabContent">
						
						<div class="noticeBlock">
							<h3>《<cfoutput>#rs_bookEntity.book_name#</cfoutput>》</h3>
							<p>
								<span class="img icon16x16 message"></span>
								如需要修改教材信息, <a href="javascript:showBookModify();">可以通过点击这里进行</a>. 
							</p>
							<hr/>
						</div>
						
						<div class="UIDashBoard">
						
							<div class="col2">
								<div class="noticeBlock">
									<p>基本信息</p>
									<cfif mathAdvice.isISBN( rs_bookEntity.book_isbn )>
										
										<p>
											<em><cfoutput>#dictAdvice.getISBN( rs_bookEntity.book_isbn )#</cfoutput></em>
											<cfset tagISBN = rs_bookEntity.book_isbn />
											<cfif len(tagISBN) eq 10>
												<cfset tagISBN = mathAdvice.upgradeISBN(tagISBN) />
												,<em><cfoutput>#dictAdvice.getISBN( tagISBN )#</cfoutput></em>
											</cfif>
										</p>
									</cfif>
									<ol>
										<li>作者: <cfoutput>#replace( rs_bookEntity.book_authors, "/", ", ", "ALL")#</cfoutput></li>
										<li>出版社 <cfoutput>#rs_bookEntity.publisher#</cfoutput> - <cfoutput>#dictAdvice.getBookEdition( rs_bookEntity.book_edition, ', ')#</cfoutput></li>
										<li>定价 <strong><cfoutput>#numberFormat( rs_bookEntity.book_prise, '____.__')#</cfoutput></strong></li>
										<li>库存 <strong><cfoutput>#rs_bookEntity.book_stock#</cfoutput></strong> 本</li>
									</ol>
								</div>
								
								<cfif len(rs_bookEntity.book_awards)>
									<div class="noticeBlock">
										<p>备注</p>
										<cfoutput>#strAdvice.XHTMLParagraphFormat( rs_bookEntity.book_awards )#</cfoutput>
									</div>
								</cfif>
								
							</div>
						
							<div class="col2 last">
								<div class="noticeBlock">
									<cfif mathAdvice.isISBN( rs_bookEntity.book_isbn )>
										<h3>印刷品条码</h3>
										<p><span class="img icon16x16 message"></span>该条码用于生成征订数据时, 教材的唯一识别码</p>
										<br/>
										<cfset tagISBN = rs_bookEntity.book_isbn />
										<cfif len(tagISBN) eq 10>
											<cfset tagISBN = mathAdvice.upgradeISBN(tagISBN) />
										</cfif>
										<p><img src="<cfoutput>#getContextRoot()#</cfoutput>/barcode/ISBN/<cfoutput>#tagISBN#</cfoutput>.png" /></p>
									</cfif>
								</div>
							</div>
						
						</div>
						
					</div>

					<div id="BookEdit" class="tabContent">
						
						<div class="noticeBlock">
							<h3>《<cfoutput>#rs_bookEntity.book_name#</cfoutput>》 修订</h3>
							<p>
								<span class="img icon16x16 message"></span>
								请注意规范填写教材书名, 作者及ISBN信息
							</p>
							<hr/>
						</div>
						
						<!-- editBook -->
						<form id="formEditBook" onSubmit="javascript:return processVerfiyForm('formEditBook');" class="formWrapper" method="post" action="<cfoutput>#buildURL('bookModifyDo')#</cfoutput>">
						
							<input name="BookID" type="hidden" value="<cfoutput>#rs_bookEntity.bid#</cfoutput>" />
							<input name="BID" type="hidden" value="<cfoutput>#rs_bookEntity.bid#</cfoutput>" />

							<div class="label">
								<span class="req">*</span><b>书名</b>
								<cfset bookName = replace(rs_bookEntity.book_name, '"', "", "ALL") />
								<input name="BookName" id="BookName" type="text" class="typeTextShort" verification="required" maxlength="80" value="<cfoutput>#event.getArg('BookName', bookName)#</cfoutput>" />
							</div>
							
							<div class="label">
								<b>拼音检索信息</b>
								<input name="PinYin" id="PinYin" type="text" class="typePinYinIdx" maxlength="30" value="<cfoutput>#event.getArg('PinYin', rs_bookEntity.pyidx)#</cfoutput>" />
							</div>
							
							<div class="label">
								<span class="req">*</span><b>作者</b>
								<input name="Authors" id="Authors" type="text" class="typeTextShort" verification="required" maxlength="50" value="<cfoutput>#event.getArg('Authors', replace( rs_bookEntity.book_authors, '/', ', ', 'ALL') )#</cfoutput>" />
							</div>
							
							<div class="label">
								<span class="req">*</span><b>定价</b>
								<input name="Prise" id="Prise" type="text" class="typeSmallInt" verification="double" maxlength="7" value="<cfoutput>#event.getArg('Prise', numberFormat(rs_bookEntity.book_prise, '_.__'))#</cfoutput>" />
							</div>

							<hr/>
							
							<div class="label">
								<b>出版社</b>
								<select name="PubID" class="inlinePart">
                                    <cfloop query="rs_pub">
										<option <cfif rs_bookEntity.pid eq rs_pub.pid>selected="selected"</cfif> value="<cfoutput>#rs_pub.pid#</cfoutput>"><cfoutput>#rs_pub.publisher#</cfoutput></option>
									</cfloop>
								</select>
							</div>
							
							<div class="label">
								<b>ISBN</b>
								<input name="ISBN" id="ISBN" type="text" class="typeISBN <cfif len(bookExId)>typeError</cfif>" verification="ISBN" maxlength="17" value="<cfoutput>#event.getArg('ISBN', rs_bookEntity.book_isbn)#</cfoutput>" />
								<cfif len(bookExId)>
									<p class="notice">该 ISBN 号在系统中已被注册</p>
								</cfif>
							</div>
							
							<div class="label">
								<b>版次</b>
								<select name="Edition1" class="inlinePart">
									<option value="YYYY">未知</option>
									<cfloop from="#year(now())#" to="#year(now())-25#" step="-1" index="e">
										<option <cfif listFirst( rs_bookEntity.book_edition, ".") eq e>selected="selected"</cfif> value="<cfoutput>#e#</cfoutput>"><cfoutput>#e#</cfoutput>年</option>
									</cfloop>
								</select>
								<select name="Edition2" class="inlinePart">
									<cfloop from="1" to="9" index="e">
									<option <cfif listLast( rs_bookEntity.book_edition, ".") eq e>selected="selected"</cfif> value="<cfoutput>#e#</cfoutput>">第<cfoutput>#strAdvice.ChineseNumber(e)#</cfoutput>版</option>
									</cfloop>
								</select>
							</div>
							
							<div class="label">
								<b>获奖情况及其他</b>
								<textarea name="Awards"><cfoutput>#event.getArg('Awards', rs_bookEntity.book_awards)#</cfoutput></textarea>
							</div>

							<hr/>
						
							<div class="lable">
								<input class="button" type="submit" value="修改" />
							</div>
							
						</form>
						
					</div>
					
					<div id="BookDelete" class="tabContent">
						
						<div class="systemNotice">
							<h3><span class="img icon16x16 info"></span>删除教材信息</h3>
							<p>注意: 删除注册教材信息的同时, 会同时删除与教材相关的征订计划,库存, 出入库单等数据信息. </p>
					
							<form id="formRemove" class="formWrapper Transparent" method="post" action="<cfoutput>#buildURL('bookRemoveDo')#</cfoutput>">
								<input name="BookID" type="hidden" value="<cfoutput>#rs_bookEntity.bid#</cfoutput>" />
								<div class="lable"><input class="button2" type="submit" value="删除教材" /></div>
							</form>
						</div>
						
					</div>
					
				</cfif>
				
			</div>
		</li>
	</ul>
</div>



